function excecuteLocalization(arrFiles, level){
	$.each(arrFiles, function (index, value) {
		doLocalize(value, level)
	});
}

function doLocalize(pageName, level){

	//alert(pageName);

	var lang = {
			autoDetect: true,	//This tells the APP to detect the language preference and load the translation file automatically
			langPref: "en",		// if you set "autoDetect:false" you should mention the name of the translation file you want to load 
			langBundle:"lang",	//folder name that contains all translation files
			fileExtention: ".json"
	}
	
	var locale = window.localStorage.getItem("locale");
	globalLocale = locale;
	
	if(locale && locale!=""){
		lang.langPref = lang.langBundle.toString() + '/' + pageName + '_' + locale + lang.fileExtention;
	} else{
		
		if(lang.autoDetect){
			navigator.globalization.getLocaleName(
				function (locale) {
					  //alert('locale: ' + locale.value + '\n');
					  var arrLocale = locale.value.split("_");
					  locale.value = arrLocale[0];
					  globalLocale = locale.value;
					  //alert('locale: ' + locale.value + '\n');
					  
					  lang.langPref = lang.langBundle.toString() + '/' + pageName + '_' + locale.value + lang.fileExtention;
					  $('html').attr('lang',locale.value);
				},
				function () {
					alert('Error getting locale. Using default: ' + lang.langPref);
					globalLocale = lang.langPref;
					$('html').attr('lang',lang.langPref.toString());
					lang.langPref = lang.langBundle.toString() + '/' + pageName + '_' + lang.langPref + lang.fileExtention;
				}
			);
		} else {
			$('html').attr('lang',lang.langPref.toString());
			lang.langPref = lang.langBundle.toString() + '/' + pageName + '_' + lang.langPref + lang.fileExtention;
		}
	
	}
	
	if(level){
		lang.langPref = level + lang.langPref;
	}
	
	//alert(lang.langPref);
	
	$.ajax({
	    	url:lang.langPref,
	    	dataType:'JSON',
	    	'global': false,
	    	'async': false,
	    	success: function(data){
	    		//alert(data);
		    	$.each(data, function(key, val) {
		    		//alert("key:" + key + ", val: " + val);
		    		$("[data-translate='localize']").each(function(){
		    			//alert("tengo: " + $(this).html() + ", busco: " + key);
		    			if(key == $(this).html()){
		    				//alert("reemplazo por: " + val);
		    				$(this).html(val);
		    				//return false;
		    			}
	    			});
	    		});
		    	
		    	var interval = setInterval(function(){
	    	        $.mobile.loading('hide');
	    	        clearInterval(interval);
	    	        $("[data-role='page']").fadeIn("slow");
	    	    },1);
		    },
		    error: function (xhr, ajaxOptions, thrownError) {
		        alert(xhr.status);
		        alert(thrownError);
		      }
	});
}